package com.usian.user.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.usian.model.common.dtos.PageResponseResult;
import com.usian.model.common.dtos.ResponseResult;
import com.usian.model.common.enums.AppHttpCodeEnum;
import com.usian.model.user.dtos.AuthDto;
import com.usian.model.user.pojos.ApUserRealname;
import com.usian.user.mapper.ApUserRealnameMapper;
import com.usian.user.service.ApUserRealnameService;
import org.springframework.stereotype.Service;

@Service
public class ApUserRealnameServiceImpl extends ServiceImpl<ApUserRealnameMapper, ApUserRealname>
        implements ApUserRealnameService {


    @Override
    public ResponseResult findPage(AuthDto dto) {

        if(dto==null ||dto.getStatus()==null){
            return ResponseResult.errorResult(AppHttpCodeEnum.PARAM_INVALID);
        }
        dto.checkParam();


        QueryWrapper<ApUserRealname> queryWrapper =new QueryWrapper<>();

        if(dto.getStatus()!=null && dto.getStatus()!=3){
            queryWrapper.lambda().eq(ApUserRealname::getStatus,dto.getStatus());
        }
        Page page = new Page(dto.getPage(), dto.getSize());

        IPage result =page(page,queryWrapper);

        ResponseResult responseResult =new PageResponseResult(dto.getPage(),dto.getSize(),(int)result.getTotal());
        responseResult.setData(result.getRecords());
        return responseResult;
    }

    public static final Short PASS_AUTH = 9;
    public static final Short FAIL_AUTH = 2;

    /**
     * 普通用户 申请成为自媒体用户 审核方法     审核（9，2） 9--》wemedia wmuser ---》article apauthor | 2---》失败原因--》
     * @param dto
     * @param status
     * @return
     */
    @Override
    public ResponseResult updateStatusById(AuthDto dto, Short status) {

        //
        return null;
    }
}
